# LogVision 构建脚本 (PowerShell)
Write-Host "========================================" -ForegroundColor Green
Write-Host "LogVision 构建脚本" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""

Write-Host "正在构建前端..." -ForegroundColor Yellow
npm run build
if ($LASTEXITCODE -ne 0) {
    Write-Host "前端构建失败！" -ForegroundColor Red
    Read-Host "按回车键退出"
    exit 1
}
Write-Host "前端构建成功！" -ForegroundColor Green
Write-Host ""

Write-Host "正在构建 Tauri 应用..." -ForegroundColor Yellow
npm run tauri build
if ($LASTEXITCODE -ne 0) {
    Write-Host "Tauri 构建失败！" -ForegroundColor Red
    Read-Host "按回车键退出"
    exit 1
}

Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host "构建完成！" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""

Write-Host "生成的文件：" -ForegroundColor Cyan
Write-Host "- 可执行文件: src-tauri\target\release\logvision.exe" -ForegroundColor White
Write-Host "- NSIS 安装包: src-tauri\target\release\bundle\nsis\logvision_0.1.0_x64-setup.exe" -ForegroundColor White
Write-Host "- MSI 安装包: src-tauri\target\release\bundle\msi\logvision_0.1.0_x64_en-US.msi" -ForegroundColor White
Write-Host ""

# 显示文件大小信息
$exePath = "src-tauri\target\release\logvision.exe"
$nsisPath = "src-tauri\target\release\bundle\nsis\logvision_0.1.0_x64-setup.exe"
$msiPath = "src-tauri\target\release\bundle\msi\logvision_0.1.0_x64_en-US.msi"

if (Test-Path $exePath) {
    $exeSize = (Get-Item $exePath).Length / 1MB
    Write-Host "可执行文件大小: $([math]::Round($exeSize, 2)) MB" -ForegroundColor Gray
}

if (Test-Path $nsisPath) {
    $nsisSize = (Get-Item $nsisPath).Length / 1MB
    Write-Host "NSIS 安装包大小: $([math]::Round($nsisSize, 2)) MB" -ForegroundColor Gray
}

if (Test-Path $msiPath) {
    $msiSize = (Get-Item $msiPath).Length / 1MB
    Write-Host "MSI 安装包大小: $([math]::Round($msiSize, 2)) MB" -ForegroundColor Gray
}

Write-Host ""
Read-Host "按回车键退出"
